package com.zkthink.ceres.common.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * Created by kellen on 2020/5/31.
 */
@AllArgsConstructor
@NoArgsConstructor
@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@ApiModel(value = "StoreDailyStatisticEnum", description = "店铺埋点-枚举")
public enum StoreDailyStatisticEnum {

  PV("pv"),
  ADD_CART("add_cart"),
  SETTLE("settle"),
  PAY("pay"),
  PAY_SUCCESS("pay_success");


  @ApiModelProperty(value = "缓存key")
  private String key;

  public static StoreDailyStatisticEnum match(String val, StoreDailyStatisticEnum def) {
    for (StoreDailyStatisticEnum enm : StoreDailyStatisticEnum.values()) {
      if (enm.name().equalsIgnoreCase(val)) {
        return enm;
      }
    }
    return def;
  }

  public static StoreDailyStatisticEnum get(String val) {
    return match(val, null);
  }

  public boolean eq(String val) {
    return this.name().equalsIgnoreCase(val);
  }

  public boolean eq(StoreDailyStatisticEnum val) {
    if (val == null) {
      return false;
    }
    return eq(val.name());
  }

  public String getCode() {
    return this.name();
  }

}
